<?php
include_once 'user_class.php';
include_once 'db_manage.php';

function getUserArray($sql) {	
	$user_array = array ();
	$result = mysql_query ( $sql );
	$i = 0;
	while ( ($rs = mysql_fetch_object ( $result )) != false ) {
		$user = new User ();
		$user->setUid ( $rs->uid );
		$user->setUsername ( $rs->username );
		$user->setGroupid ( $rs->groupid );
		$user->setGrouptitle ( $rs->grouptitle );
		$user->setStars ( $rs->stars );
		$user->setCredits ( $rs->credits );
		$user_array [$i] = $user;
		$i ++;
	}
	return $user_array;
}

function getUserById($uid) {
	$sql = "select * from cdb_members m,cdb_usergroups g where m.groupid = g.groupid and uid = " . $uid;
	$user_array = getUserArray ( $sql );	
	if (count ( $user_array ) > 0) {
		return $user_array [0];
	}else{
		return 0;
	}
}
?>